<p id="notice"><%= notice %></p>

<h1><%= t(:posts) %></h1>
<%= link_to t(:post), new_post_path %>
<table>
  <thead>
  <tr>
    <th><%= t(:postTitle) %></th>

    <th><%= t(:postOperation) %></th>
    <th><%= t(:count) %></th>
  </tr>
  </thead>

  <tbody>
  <% if @posts.nil? %>
      <tr>>><%= t(:error) %><<<</tr>
  <% else %>
      <% @posts.each do |post| %>
          <tr>
            <td><%= link_to "#{post.title}", post_path(post) %></td>
            <td>
              <% if user_login_in? && (current_user?(post.user) || @current_user.admin) %>
                  <%= link_to  t(:edit) , edit_post_path(post) %><%= link_to t(:delete), post, method: :delete, data: {confirm: 'Are you sure?'} %>
              <% end %></td>
            <td><%= post.post_relationships.count %></td>
          </tr>
      <% end %>
      <%= will_paginate @posts %>
  <% end %>
  </tbody>
</table>





